﻿using System;
using System.Collections;
using Ext.Net;
using BLL;
using Model;
using System.Collections.Generic;

namespace Web.View.userInfo
{
    public partial class Default : UIPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void InfoBind(object sender, StoreRefreshDataEventArgs e)
        {
            userinfoMgr mgr = new userinfoMgr();
            IList<userinfo> list = mgr.FindAllByPage_userinfo("0", "2", " username='" + Session["username"].ToString() + "'");
            this.userinfo_Store.DataSource = list;
            this.userinfo_Store.DataBind();
        }
        protected void GetAllRoles(object sender, StoreRefreshDataEventArgs e)
        {
            rolesMgr mgr = new rolesMgr();
            S_Roles.DataSource = mgr.FindAll_roles();
            S_Roles.DataBind();
        }
        //获取Grid的数据变换行，并保存
        protected void HandleChanges(object sender, BeforeStoreChangedEventArgs e)
        {
            userinfoMgr mgr=new userinfoMgr();
            ChangeRecords<userinfo> persons = e.DataHandler.ObjectData<userinfo>();
            foreach (userinfo updated in persons.Updated)
            {
                try
                {
                    if (mgr.Update_userinfo(updated))
                        X.Msg.Notify("成功", "<font color='green'>更新为：" + updated.username + " " + updated.usersex + " ...</font>").Show();
                }
                catch
                {
                    X.Msg.Notify("失败", "<font color='red'>该记录更新失败：" + updated.username + " " + updated.usersex + " ...</font>").Show();
                }
            }
            e.Cancel = true;
        }

    }
}
